//全屏
function full_screen(){
    var element     = document.documentElement;
    if(element.requestFullscreen) {
        element.requestFullscreen();
    } else if(element.mozRequestFullScreen) {
        element.mozRequestFullScreen();
    } else if(element.msRequestFullscreen){
        element.msRequestFullscreen();
    } else if(element.webkitRequestFullscreen) {
        element.webkitRequestFullScreen();
    }
}

//数据存储
function Data(key, val){
    key     = config.prefix_data+key;
    if(val){
        localStorage.setItem(key, JSON.stringify(val));
    }
    return JSON.parse(localStorage.getItem(key));
}

/**
 * 本地缓存读取
 * @param {string} key 键名
 * @param {object} val 键值
 */
function S(key, val){
    key     = config.prefix_cache + key;
    if(val){
        sessionStorage.setItem(key, JSON.stringify(val));
    }
    if(val === null){
        sessionStorage.removeItem(key);
    }
    return JSON.parse(sessionStorage.getItem(key));
}

/**
 * 对象转为http-get字符串
 * @param {object} object 目标对象
 * @return {string} [description]
 */
function objectToHttp(object){
    var string  = '';
    for(var i in object){
        string  = string + i + '=' + object[i] + '&';
    }
    string  = string.substring(0, string.length-1);
    return string;
}

/**
 * 复杂对象转为get参数
 * date
 * @param  {[type]} param  [description]
 * @param  {[type]} key    [description]
 * @param  {[type]} encode [description]
 * @return {[type]}        [description]
 */
function httpBuildQuery(param, key, encode){
    if(param==null) return '';
    var paramStr = '';
    var t = typeof (param);
    if (t == 'string' || t == 'number' || t == 'boolean') {
        paramStr += '&' + key + '=' + ((encode==null||encode) ? encodeURIComponent(param) : param);
    } else {
        for (var i in param) {
            var k = key == null ? i : key + '[' + i + ']';
            paramStr += httpBuildQuery(param[i], k, encode);
        }
    }
    return paramStr;
}